module App::View
    class TrayIcon < Qt::SystemTrayIcon
        slots 'task_stopped()'
        slots 'taskRunning(QObject*, int)'
        
        def initialize()
            super()

            task_stopped
            show
        end
        
        private
        def task_stopped()
            icon = Qt::Icon.new(File.dirname($0)+"/icons/karm.png")
            #icon.setAcceptDrops(true)
            setIcon icon
        end

        def taskRunning(runningtask, ticker)
            iconfile = File.dirname($0)+"/icons/user-away.png" if (ticker%2).zero?
            iconfile = File.dirname($0)+"/icons/user-away-extended.png" unless (ticker%2).zero?
            setIcon Qt::Icon.new(iconfile)
        end
    end
end
